home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / ll_arc_distance.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  86 lines

  1. ; $Id: ll_arc_distance.pro,v 1.5 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1992-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5.  
  6. FUNCTION LL_ARC_DISTANCE, lon_lat0, arc_dist, az, DEGREES = degs
  7. ;+
  8. ; NAME:
  9. ;    LL_ARC_DISTANCE
  10. ;
  11. ; PURPOSE:
  12. ;     This function returns the longitude and latitude [lon, lat] of
  13. ;    a point a given arc distance (-pi <= Arc_Dist <= pi), and azimuth (Az),
  14. ;    from a specified location Lon_lat0.
  15. ;
  16. ; CATEGORY:
  17. ;    Mapping, geography.
  18. ;
  19. ; CALLING SEQUENCE:
  20. ;    Result = LL_ARC_DISTANCE(Lon_lat0, Arc_Dist, Az)
  21. ;
  22. ; INPUTS:
  23. ;        Lon_lat0: A 2-element vector containing the longitude and latitude
  24. ;          of the starting point. Values are assumed to be in radians
  25. ;          unless the keyword DEGREES is set.
  26. ;        Arc_Dist: The arc distance from Lon_lat0. The value must be between
  27. ;          -!PI and +!PI. To express distances in arc units, divide
  28. ;          by the radius of the globe expressed in the original units.
  29. ;          For example, if the radius of the earth is 6371 km, divide
  30. ;          the distance in km by 6371 to obtain the arc distance.    
  31. ;        Az:      The azimuth from Lon_lat0. The value is assumed to be in
  32. ;          radians unless the keyword DEGREES is set.
  33. ;
  34. ; KEYWORD PARAMETERS:
  35. ;        DEGREES:  Set this keyword to express all measurements and
  36. ;          results in degrees.
  37. ;
  38. ; OUTPUTS:
  39. ;    This function returns a two-element vector containing the
  40. ;    longitude and latitude of the resulting point. Values are
  41. ;    in radians unless the keyword DEGREES is set.
  42. ;
  43. ; PROCEDURE:
  44. ;    Formula from Map Projections - a working manual.  USGS paper
  45. ;    1395.  Equations (5-5) and (5-6).
  46. ;
  47. ; EXAMPLE:
  48. ;    Lon_lat0 = [1.0, 2.0]        ; Initial point specified in radians    
  49. ;    Arc_Dist = 2.0            ; Arc distance in radians
  50. ;    Az = 1.0            ; Azimuth in radians
  51. ;    Result = LL_ARC_DISTANCE(Lon_lat0, Arc_Dist, Az)
  52. ;    PRINT, Result
  53. ;           2.91415    -0.622234
  54. ;
  55. ; MODIFICATION HISTORY:
  56. ;    DMS, Aug, 1992.  Written.
  57. ;       DJC, Jun, 1994.  Added test for zero arc distance.
  58. ;                        Renamed "dist" variable to "arc_dist" for
  59. ;                        compatibility with IDL "Dist" function.
  60. ;-
  61.  
  62. ; Return the [lon, lat] of the point a given arc distance 
  63. ;    (-pi <= arc_dist <= pi),
  64. ; and azimuth (az), from lon_lat0.
  65. ;
  66.  
  67. if (arc_dist eq 0) then return, lon_lat0
  68.  
  69. cdist = cos(arc_dist)        ;Arc_Dist is always in radians.
  70. sdist = sin(arc_dist)
  71.  
  72. if keyword_set(degs) then s = !dtor else s = 1.0
  73.  
  74. ll = lon_lat0 * s    ;To radians
  75. sinll1 = sin(ll[1])
  76. cosll1 = cos(ll[1])
  77. phi = asin(sinll1 * cdist + cosll1 * sdist * cos(az * s))
  78. lam = ll[0] + atan(sdist * sin(az * s), $
  79.     cosll1*cdist - sinll1 * sdist * cos(az * s))
  80. while lam lt -!pi do lam = lam + 2 * !pi
  81. while lam gt !pi do lam = lam - 2 * !pi
  82. return, [lam, phi] / s
  83. end
  84.  
  85.  
  86.